#!/usr/bin/python
# -*- coding:utf-8 -*-
#选择排序
#@author: wklken@yeah.net

def select_sort(l):
    
    index = len(l) -1
    while index:
        max = l[index]
        max_index = index
        for i in range(index):
            if l[i] > max:
                max = l[i]
                max_index = i
        if max > l[index]:
            l[index],l[max_index] = l[max_index], l[index]
        index -= 1
        print l
        
l = [8, 4, 3, 7, 6, 5, 2, 1]
select_sort(l)  
            